package PRUEBAS;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class QuitaDecimalesTest {


	public static String formateador( BigDecimal number ) {		
		
		StringBuilder s = new StringBuilder( number.toPlainString() );
		
		System.out.println( "INICIO: " + s +" / "+ (s.length()-1) +", "+ s.indexOf(".") );
		
		for( int i = s.length()-1 ; s.indexOf(".") != -1 && i > -1 ; i-- ) {
			//System.out.println( s.charAt(i) );
			if( s.charAt(i) == '0' || s.charAt(i) == '.' ) {
				s.deleteCharAt(i);
			} else {
				break;
			}
		}
		
		System.out.println( "FIN:    " + s );
		
		return s.toString();
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		//BigDecimal bd = BigDecimal.ZERO.setScale( 7 );
		//System.out.println( "BD: " + bd + ", " + bd.toPlainString() + ", " + bd.toPlainString().indexOf(".") );
		
		//BigDecimal bd1 = new BigDecimal("129.03251234");
		
		//System.out.println( "BD1: " + bd1.abs().toPlainString() + ", " + bd1.scale() );
		//System.out.println( bd1.intValue() );
		
		//BigDecimal bd2 = bd1.setScale(0, RoundingMode.HALF_UP);
		
		//System.out.println( "BD2: " + bd2.toPlainString() );
		
		formateador( new BigDecimal("129.0325123") );
		formateador( new BigDecimal("129.0325000") );
		formateador( new BigDecimal("129.0000000") );
		formateador( new BigDecimal("0.0000000") );			
	}
}